package com.aiit.carinsurance2.controller;

import com.aiit.carinsurance2.pojo.*;
import com.aiit.carinsurance2.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpSession;
import java.util.List;
@Controller

public class ManagerController {


    @Autowired
    private ToubaodanService toubaodanService;

    @Autowired
    private CarService carService;

    @RequestMapping("/styles")
    public String getmanager(){
        return "styles";
    }

    @Autowired
    private CarinsuranceService carinsuranceService;

    @Autowired
    private FinallylistinfoService finallylistinfoService;

    @GetMapping("/addbasiscarinfo")
    public String gerbasiscarinfo(){
        return "addbasiscarinfo";
    }
    @PostMapping("/addbasiscarinfo")
    public String postcarinfos(Choosecar choosecar){
        int rlt=carService.addbasiscarinfo(choosecar);
        return "styles";
    }
    @GetMapping("/addinsurance")
    public String getadd(){return "addinsurance";}
    @PostMapping("/addinsurance")
    public String addinsurance(Carinsurance carinsurance){
        int rlt=carinsuranceService.addinsurance(carinsurance);
        return "redirect:/styles";
    }


    @GetMapping("/finallylist")
    public ModelAndView finallylist(){
        System.out.println(222);
        ModelAndView mav=new ModelAndView();
        Finallylistinfo queryfinallylist = finallylistinfoService.queryfinallylist1();
        Integer uid = queryfinallylist.getUid();
        System.out.println(queryfinallylist.getUname());
        List<Finallylistinfos> finallylistinfos = finallylistinfoService.queryfinallylist2(uid);
        mav.addObject("queryfinallylist",queryfinallylist);

        mav.addObject("finallylistinfos",finallylistinfos);
        mav.setViewName("finallylist");
        return mav;
    }








}
